package cn.demo.sys.domain;

import cn.demo.common.core.domain.BaseEntity;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.xss.Xss;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 通知公告表 sys_notice
 *
 * @author ruoyi
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "sys_notice",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class SysNotice extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 公告ID
     */
    @Id
    private String noticeId;

    /**
     * 公告标题
     */
    @Xss(message = "公告标题不能包含脚本字符")
    @NotBlank(message = "公告标题不能为空")
    @Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
    private String noticeTitle;

    /**
     * 公告类型（1通知 2公告）
     */
    private Integer noticeType;

    /**
     * 公告内容
     */
    private String noticeContent;

    /**
     * 公告状态（0正常 1关闭）
     */
    private Integer status;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = SqlOperators.of()
            .set(SysNotice::getNoticeTitle, SqlOperator.LIKE)
            .set(SysNotice::getCreateBy, SqlOperator.LIKE);
}
